package mazeAssignment;

import javax.swing.JApplet;
import javax.swing.SwingUtilities;

public class MazeApplet extends JApplet
{
	private static final long serialVersionUID = 1L;

	/**
	 * Run when the applet is loaded by the browser (before 'start()').
	 */
	@Override
	public void init()
	{
		String lOperationMode = getParameter("mode");
		if(lOperationMode != null && lOperationMode.equals("benchmark"))
		{
			SwingUtilities.invokeLater(new GTInitBenchmarkApplet());
		}
		else
		{
			SwingUtilities.invokeLater(new GTInitApplet());
		}
	}
	
	/**
	 * Run when the applet is started by the browser (after 'init()').
	 */
	@Override
	public void start()
	{
		
	}
	
	/**
	 * Run when the applet is stopped by the browser.
	 */
	@Override
	public void stop()
	{
		
	}

	/**
	 * Run when the applet is destroy by the browser (last function called by the browser).
	 */
	@Override
	public void destroy()
	{
		
	}
	
	private class GTInitApplet implements Runnable
    {
    	public void run()
    	{
    		new Manager(MazeApplet.this, MazeApplet.this.getContentPane());

    		MazeApplet.this.setVisible(true);
    	}
    }
	
	private class GTInitBenchmarkApplet implements Runnable
    {
    	public void run()
    	{
    		new Benchmark(MazeApplet.this);

    		MazeApplet.this.setVisible(true);
    	}
    }
}
